<%@ page language="java" import="com.baomidou.mybatisplus.extension.plugins.pagination.Page" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    Page page1 = (Page) session.getAttribute("page");
    Long pages = (Long) session.getAttribute("pages");
    boolean head = false;
    boolean tail = false;
    if (page1 != null) {
        if (page1.getCurrent() == 1) {
            head = true;
        }
        if (page1.getCurrent() == pages) {
            tail = true;
        }
    }
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>新闻中国</title>
    <link href="../../../static/css/main.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="../../../static/js/jquery-1.12.4.min.js"></script>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<div style="max-width: 500px">
    <input id="mysearch" style="border-color: #333333;padding-left: 2px" placeholder="请输入需要搜索的内容"
           type="text">
    <button type="submit" onclick="search()">搜索</button>
</div>

<div align="content" style="min-width: 500px;float: left">
    <ul class="class_date" style="max-width: 500px">
        <!-- 新闻主题链接区域 -->
        <li id='class_month'><a onclick="queryPageByTopic(0)"><b>全部</b></a></li>
        <c:forEach items="${sessionScope.topic}" var="item">
            <li id='class_month'><a onclick="queryPageByTopic(${item.tid})"><b>${item.tname}</b></a></li>
        </c:forEach>
    </ul>
</div>
<div>
    <ul class="classlist">
        <%--            href="/admin/toEditPage/${item.nid}?authentication=${sessionScope.authentication}"--%>
        <c:forEach items="${sessionScope.news}" var="item" varStatus="status">
            <li><a>${item.ntitle}</a><span style="padding-right: 140px">${item.ncreatedate}</span><span>${item.nauthor}&nbsp;&nbsp;<button href="" onclick="toEdit(${item.nid})">修改</button>&nbsp;&nbsp;<button
                    onclick="delNews(${item.nid})">删除</button></span></li>
            <c:if test="${(status.index+1)%5 == 0}">
                <li class='space'></li>
            </c:if>
        </c:forEach>
    </ul>
    <p align="center">
        <span>当前页数:[${sessionScope.page.current}/${sessionScope.pages}]</span>
    </p></p>
    <p align="center">
        <button onclick="selectPage(1)">首页</button>
        <button onclick="selectPage(${sessionScope.page.current}-1)" <%=head ? "disabled" : ""%>>上一页</button>
        <button onclick="selectPage(${sessionScope.page.current}+1)" <%=tail ? "disabled" : ""%>>下一页</button>
        <button onclick="selectPage(${sessionScope.pages})">末页</button>
    </p>
</div>
</body>
</html>
